package com.example.propertymangesystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.propertymangesystem.domain.employee;
import com.example.propertymangesystem.mapper.employeeMapper;
import com.example.propertymangesystem.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class employeeServiceImpl extends ServiceImpl<employeeMapper, employee> implements IEmployeeService {
    @Autowired
    private employeeMapper employeeMapper;

    @Override
    public List<employee> getDepartmentAll(Integer did) {
        return employeeMapper.getDepartmentAll(did);
    }

    @Override
    public IPage<employee> getPage(Integer current, Integer size,  employee employee) {
        QueryWrapper<employee> qw = new QueryWrapper<>();
        qw.like(employee.getId() != null, "id", employee.getId());
        qw.like(employee.getDid() != null, "did", employee.getDid());
        qw.like(employee.getName() != null, "name", employee.getName());
        IPage page = new Page(current, size);
        employeeMapper.selectPage(page, qw);
        return page;
    }
}
